using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class tbNhaSXBUS
    {
        public static void Insert(tbNhaSX nhasx)
        {
            tbNhaSXDAL nsxDAL = new tbNhaSXDAL();
            nsxDAL.Insert(nhasx);
        }
        public static void Update(tbNhaSX nhasx)
        {
            tbNhaSXDAL nsxDAl = new tbNhaSXDAL();
            nsxDAl.Update(nhasx);
        }
        public static void Delete(int iD)
        {
            tbNhaSXDAL nsxDAl = new tbNhaSXDAL();
            nsxDAl.Delete(iD);
        }
        public static tbNhaSXCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbNhaSXDAL nsxDAL = new tbNhaSXDAL();
            return nsxDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbNhaSXCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbNhaSXDAL nsxDAL = new tbNhaSXDAL();
            return nsxDAL.Get(cri.Criter, 0, 0, tbNhaSXColumns.MaNSX.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbNhaSX GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbNhaSXColumns.MaNSX.ToString(), Condition.EQUAL, iD);
            tbNhaSXDAL nsxDAL = new tbNhaSXDAL();
            tbNhaSXCollection nsxCollection = nsxDAL.Get(cri.Criter, 0, 0, tbNhaSXColumns.MaNSX.ToString(), OrderDirection.ASC.ToString(), out total);
            if (nsxCollection.Count > 0)
                return nsxCollection[0];
            return null;
        }
        public static tbNhaSXCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbNhaSXDAL nsxDAL = new tbNhaSXDAL();
            return nsxDAL.Get(cri.Criter, 1, number, tbNhaSXColumns.MaNSX.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbNhaSXCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbNhaSXDAL nsxDAL = new tbNhaSXDAL();
            return nsxDAL.Get(cri.Criter, 1, number, tbNhaSXColumns.MaNSX.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}